package com.example.tests;


public class GroupData implements Comparable<GroupData>{
	private String grId;
	private String grName;
	private String grHeader;
	private String grFooter;

	public GroupData() {
	}
	
	public GroupData(String grName, String grHeader, String grFooter) {
		this.grName = grName;
		this.grHeader = grHeader;
		this.grFooter = grFooter;
	}

	public String getGrId() {
		return grId;
	}

	public String getGrName() {
		return grName;
	}

	public String getGrHeader() {
		return grHeader;
	}

	public String getGrFooter() {
		return grFooter;
	}

	public void setGrId(String grId) {
		this.grId = grId;
	}

	public void setGrName(String grName) {
		this.grName = grName;
	}

	public void setGrHeader(String grHeader) {
		this.grHeader = grHeader;
	}

	public void setGrFooter(String grFooter) {
		this.grFooter = grFooter;
	}

	@Override
	public String toString() {
		return "GroupData [grName=" + grName + ", grHeader=" + grHeader
				+ ", grFooter=" + grFooter + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((grName == null) ? 0 : grName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GroupData other = (GroupData) obj;
		if (grName == null) {
			if (other.grName != null)
				return false;
		} else if (!grName.equals(other.grName))
			return false;
		return true;
	}

	@Override
	public int compareTo(GroupData other) {
		return this.grName.toLowerCase().compareTo(other.grName.toLowerCase());
	}

	public GroupData withId(String id) {
		grId = id;
		return this;
	}

	public GroupData withName(String name) {
		grName = name;
		return this;
	}

	public GroupData withHeader(String header) {
		grHeader = header;
		return this;
	}

	public GroupData withFooter(String footer) {
		grFooter = footer;
		return this;
	}

	// update with values of non-empty fields of group, other fields are not touched
	public void updateGroup(GroupData group) {
		if (group.grName.isEmpty() == false) {this.grName = group.grName;}
		if (group.grHeader.isEmpty() == false) {this.grHeader = group.grHeader;}
		if (group.grFooter.isEmpty() == false) {this.grFooter = group.grFooter;}
	}
	
}